{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Imports\n",
    "\n",
    "Import all the modules and functionalities we need."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "\n",
    "# Import standard libraries.\n",
    "import os\n",
    "\n",
    "# Import third party libraries.\n",
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "import seaborn as sns\n",
    "from statsmodels.stats.multitest import multipletests\n",
    "from statsmodels.stats.proportion import proportions_ztest\n",
    "\n",
    "# Import custom libraries/scripts.\n",
    "import annotations\n",
    "import helpers"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Loading data\n",
    "\n",
    "Fetch all our relevant data for the current analysis."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Set working contants.\n",
    "EXPERIMENTS_PATH = r'\\\\10.40.12.80\\home\\PhD\\Results\\Competition\\DL\\small_arenas\\Or67d\\crossed_with_white_minus\\processed'\n",
    "FPS = 60\n",
    "N_MINUTES = 5\n",
    "N_FRAMES = N_MINUTES * 60 * FPS # First five minutes of copulation.\n",
    "INK = 'black'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Set figure configurations.\n",
    "sns.set(\n",
    "        context='paper',\n",
    "        style='ticks',\n",
    "        font='sans-serif',\n",
    "        font_scale=1.0, \n",
    "        rc={\n",
    "            'axes.axisbelow': True,\n",
    "            'axes.edgecolor': INK,\n",
    "            'axes.facecolor': 'white' if INK=='black' else 'black',\n",
    "            'axes.grid': False,\n",
    "            'axes.labelcolor': INK,\n",
    "            'axes.labelsize': 13.0,\n",
    "            'axes.labelweight': 'normal',\n",
    "            'axes.linewidth': 1.0,\n",
    "            'axes.spines.left': True,\n",
    "            'axes.spines.bottom': True,\n",
    "            'axes.spines.top': False,\n",
    "            'axes.spines.right': False,\n",
    "            'axes.titlepad': 15.0,\n",
    "            'axes.titlesize': 20.0,\n",
    "            'axes.titleweight': 'bold',\n",
    "            'figure.facecolor': 'white' if INK=='black' else 'black',\n",
    "            'figure.figsize': [4.0, 4.0],\n",
    "            'figure.titlesize': 30.0,\n",
    "            'figure.titleweight': 'bold',\n",
    "            'font.family': ['sans-serif'],\n",
    "            'font.sans-serif': ['Arial'],\n",
    "            'legend.frameon': False,\n",
    "            'legend.fontsize': 11.0,\n",
    "            'lines.color': INK,\n",
    "            'lines.linewidth': 1.0,\n",
    "            'patch.edgecolor': INK,\n",
    "            'savefig.dpi': 300,\n",
    "            'savefig.format': 'png',\n",
    "            'savefig.bbox': 'tight',\n",
    "            'savefig.transparent': True,\n",
    "            'text.color': INK,\n",
    "            'text.usetex': False,\n",
    "            'xtick.color': INK,\n",
    "            'xtick.direction': 'out',\n",
    "            'xtick.labelsize': 12.0,\n",
    "            'xtick.major.pad': 5.0,\n",
    "            'xtick.major.size': 0.0,\n",
    "            'xtick.major.width': 1.0,\n",
    "            'xtick.minor.size': 0.0,\n",
    "            'xtick.minor.width': 0.4,\n",
    "            'ytick.color': INK,\n",
    "            'ytick.direction': 'out',\n",
    "            'ytick.labelsize': 12.0,\n",
    "            'ytick.major.pad': 5.0,\n",
    "            'ytick.major.size': 3.0,\n",
    "            'ytick.major.width': 1.0,\n",
    "            'ytick.minor.size': 0.0,\n",
    "            'ytick.minor.width': 0.4\n",
    "           }\n",
    "       )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Folder already exists, skipping.\n"
     ]
    }
   ],
   "source": [
    "# Prepare the Figures folder to save our graphs in.\n",
    "savepath = os.path.join(r'C:\\Users\\Miguel\\Desktop\\paper_data', 'paper_figures', 'figure4')\n",
    "try:\n",
    "    os.makedirs(savepath)\n",
    "    print(\"New folder created.\")\n",
    "except FileExistsError:\n",
    "    print(\"Folder already exists, skipping.\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Paths to conditions:\n",
      " ['\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control', '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test', '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control']\n"
     ]
    }
   ],
   "source": [
    "# Set the conditions to analyze.\n",
    "condition_order = ['gal4_control', 'uas_control', 'test']\n",
    "conditions = [item.path for item in os.scandir(EXPERIMENTS_PATH) if item.name in condition_order]\n",
    "print('Paths to conditions:\\n', conditions)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\t\n",
      " gal4_control\n",
      "\t\n",
      " test\n",
      "Copulation too short: video_2021-02-15T11_07_47_arena5.csv\n",
      "Copulation too short: video_2021-02-19T11_33_52_arena10.csv\n",
      "\t\n",
      " uas_control\n",
      "Copulation too short: video_2021-02-15T10_18_59_arena3.csv\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'gal4_control': ['\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-15T10_18_59_arena1.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-15T10_18_59_arena10.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-15T10_18_59_arena16.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-15T10_18_59_arena6.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-15T10_18_59_arena8.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-15T11_07_47_arena11.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-15T11_07_47_arena3.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-15T11_07_47_arena4.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-15T11_07_47_arena6.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-15T11_07_47_arena7.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-16T12_26_11_arena11.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-16T12_26_11_arena13.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-16T12_26_11_arena14.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-16T12_26_11_arena3.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-16T12_26_11_arena9.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-17T10_22_44_arena1.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-17T10_22_44_arena10.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-17T10_22_44_arena12.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-17T10_22_44_arena15.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-17T10_22_44_arena7.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-17T10_22_44_arena8.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-17T11_13_09_arena1.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-17T11_13_09_arena11.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-17T11_13_09_arena4.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-17T11_13_09_arena6.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-18T11_23_50_arena1.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-18T11_23_50_arena15.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-18T11_23_50_arena2.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-18T11_23_50_arena7.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-18T11_23_50_arena9.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-18T12_15_02_arena1.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-18T12_15_02_arena11.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-18T12_15_02_arena13.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-18T12_15_02_arena16.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-18T12_15_02_arena4.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-18T12_15_02_arena6.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-19T10_46_46_arena7.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-19T11_33_52_arena14.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-19T11_33_52_arena8.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\gal4_control\\\\video_2021-02-19T11_33_52_arena9.csv'],\n",
       " 'uas_control': ['\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-15T10_18_59_arena14.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-15T10_18_59_arena7.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-15T11_07_47_arena13.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-15T11_07_47_arena14.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-15T11_07_47_arena8.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-16T12_26_11_arena12.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-16T12_26_11_arena7.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-16T12_26_11_arena8.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-17T10_22_44_arena6.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-17T10_22_44_arena9.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-17T11_13_09_arena14.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-17T11_13_09_arena9.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-18T11_23_50_arena13.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-18T11_23_50_arena4.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-18T11_23_50_arena6.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-18T12_15_02_arena2.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-19T10_46_46_arena12.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-19T10_46_46_arena15.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-19T11_33_52_arena11.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-19T11_33_52_arena3.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\uas_control\\\\video_2021-02-19T11_33_52_arena7.csv'],\n",
       " 'test': ['\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-15T10_18_59_arena11.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-15T10_18_59_arena15.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-15T10_18_59_arena4.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-15T10_18_59_arena5.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-15T10_18_59_arena9.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-15T11_07_47_arena10.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-15T11_07_47_arena15.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-15T11_07_47_arena16.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-15T11_07_47_arena2.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-15T11_07_47_arena9.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-16T12_26_11_arena1.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-16T12_26_11_arena16.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-16T12_26_11_arena2.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-16T12_26_11_arena5.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-17T10_22_44_arena11.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-17T10_22_44_arena2.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-17T11_13_09_arena10.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-17T11_13_09_arena13.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-17T11_13_09_arena15.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-17T11_13_09_arena3.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-17T11_13_09_arena5.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-18T12_15_02_arena10.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-19T10_46_46_arena10.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-19T10_46_46_arena11.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-19T10_46_46_arena13.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-19T10_46_46_arena14.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-19T10_46_46_arena2.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-19T10_46_46_arena3.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-19T10_46_46_arena6.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-19T10_46_46_arena9.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-19T11_33_52_arena5.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Or67d\\\\crossed_with_white_minus\\\\processed\\\\test\\\\video_2021-02-19T11_33_52_arena6.csv']}"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Load all usable experiments for each condition.\n",
    "experiments = {condition: [] for condition in condition_order}\n",
    "\n",
    "for condition_path in conditions:\n",
    "    \n",
    "    condition = os.path.basename(condition_path)\n",
    "    print('\\t\\n', condition)\n",
    "    \n",
    "    for item in os.scandir(condition_path):\n",
    "        if item.name.endswith('.csv'):\n",
    "            \n",
    "            annotation_video = annotations.read(item.path)\n",
    "\n",
    "            try:\n",
    "                copulation = annotation_video[0].events[0]\n",
    "\n",
    "                # Filter out videos where copulation is interrupted.\n",
    "                copulation_end = copulation.time_interval[1]\n",
    "                if copulation_end==N_FRAMES:\n",
    "                    if copulatio.duration < 5 * 60 * FPS:\n",
    "                        print('Copulation interrupted:', item.name)\n",
    "                        continue\n",
    "\n",
    "                # Filter out videos where copulation lasts less than 8 minutes.\n",
    "                copulation_duration = copulation.duration\n",
    "                if copulation_duration <= 8 * 60 * FPS:\n",
    "                    print('Copulation too short:', item.name)\n",
    "                    continue\n",
    "            \n",
    "            except IndexError:\n",
    "                continue\n",
    "            \n",
    "            experiments[condition].append(item.path)\n",
    "\n",
    "experiments"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Aggression Analysis"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 0 \n",
      "Experiment: video_2021-02-15T10_18_59_arena1.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 1 \n",
      "Experiment: video_2021-02-15T10_18_59_arena10.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 2 \n",
      "Experiment: video_2021-02-15T10_18_59_arena16.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 3 \n",
      "Experiment: video_2021-02-15T10_18_59_arena6.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 4 \n",
      "Experiment: video_2021-02-15T10_18_59_arena8.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 5 \n",
      "Experiment: video_2021-02-15T11_07_47_arena11.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 6 \n",
      "Experiment: video_2021-02-15T11_07_47_arena3.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 7 \n",
      "Experiment: video_2021-02-15T11_07_47_arena4.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 8 \n",
      "Experiment: video_2021-02-15T11_07_47_arena6.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 9 \n",
      "Experiment: video_2021-02-15T11_07_47_arena7.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 10 \n",
      "Experiment: video_2021-02-16T12_26_11_arena11.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 11 \n",
      "Experiment: video_2021-02-16T12_26_11_arena13.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 12 \n",
      "Experiment: video_2021-02-16T12_26_11_arena14.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 13 \n",
      "Experiment: video_2021-02-16T12_26_11_arena3.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 14 \n",
      "Experiment: video_2021-02-16T12_26_11_arena9.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 15 \n",
      "Experiment: video_2021-02-17T10_22_44_arena1.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 16 \n",
      "Experiment: video_2021-02-17T10_22_44_arena10.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 17 \n",
      "Experiment: video_2021-02-17T10_22_44_arena12.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 18 \n",
      "Experiment: video_2021-02-17T10_22_44_arena15.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 19 \n",
      "Experiment: video_2021-02-17T10_22_44_arena7.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 20 \n",
      "Experiment: video_2021-02-17T10_22_44_arena8.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 21 \n",
      "Experiment: video_2021-02-17T11_13_09_arena1.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 22 \n",
      "Experiment: video_2021-02-17T11_13_09_arena11.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 23 \n",
      "Experiment: video_2021-02-17T11_13_09_arena4.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 24 \n",
      "Experiment: video_2021-02-17T11_13_09_arena6.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 25 \n",
      "Experiment: video_2021-02-18T11_23_50_arena1.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 26 \n",
      "Experiment: video_2021-02-18T11_23_50_arena15.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 27 \n",
      "Experiment: video_2021-02-18T11_23_50_arena2.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 28 \n",
      "Experiment: video_2021-02-18T11_23_50_arena7.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 29 \n",
      "Experiment: video_2021-02-18T11_23_50_arena9.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 30 \n",
      "Experiment: video_2021-02-18T12_15_02_arena1.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 31 \n",
      "Experiment: video_2021-02-18T12_15_02_arena11.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 32 \n",
      "Experiment: video_2021-02-18T12_15_02_arena13.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 33 \n",
      "Experiment: video_2021-02-18T12_15_02_arena16.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 34 \n",
      "Experiment: video_2021-02-18T12_15_02_arena4.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 35 \n",
      "Experiment: video_2021-02-18T12_15_02_arena6.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 36 \n",
      "Experiment: video_2021-02-19T10_46_46_arena7.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 37 \n",
      "Experiment: video_2021-02-19T11_33_52_arena14.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 38 \n",
      "Experiment: video_2021-02-19T11_33_52_arena8.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 39 \n",
      "Experiment: video_2021-02-19T11_33_52_arena9.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 0 \n",
      "Experiment: video_2021-02-15T10_18_59_arena14.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 1 \n",
      "Experiment: video_2021-02-15T10_18_59_arena7.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 2 \n",
      "Experiment: video_2021-02-15T11_07_47_arena13.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 3 \n",
      "Experiment: video_2021-02-15T11_07_47_arena14.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 4 \n",
      "Experiment: video_2021-02-15T11_07_47_arena8.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 5 \n",
      "Experiment: video_2021-02-16T12_26_11_arena12.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 6 \n",
      "Experiment: video_2021-02-16T12_26_11_arena7.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 7 \n",
      "Experiment: video_2021-02-16T12_26_11_arena8.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 8 \n",
      "Experiment: video_2021-02-17T10_22_44_arena6.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 9 \n",
      "Experiment: video_2021-02-17T10_22_44_arena9.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 10 \n",
      "Experiment: video_2021-02-17T11_13_09_arena14.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 11 \n",
      "Experiment: video_2021-02-17T11_13_09_arena9.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 12 \n",
      "Experiment: video_2021-02-18T11_23_50_arena13.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 13 \n",
      "Experiment: video_2021-02-18T11_23_50_arena4.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 14 \n",
      "Experiment: video_2021-02-18T11_23_50_arena6.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 15 \n",
      "Experiment: video_2021-02-18T12_15_02_arena2.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 16 \n",
      "Experiment: video_2021-02-19T10_46_46_arena12.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 17 \n",
      "Experiment: video_2021-02-19T10_46_46_arena15.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 18 \n",
      "Experiment: video_2021-02-19T11_33_52_arena11.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 19 \n",
      "Experiment: video_2021-02-19T11_33_52_arena3.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 20 \n",
      "Experiment: video_2021-02-19T11_33_52_arena7.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 0 \n",
      "Experiment: video_2021-02-15T10_18_59_arena11.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 1 \n",
      "Experiment: video_2021-02-15T10_18_59_arena15.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 2 \n",
      "Experiment: video_2021-02-15T10_18_59_arena4.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 3 \n",
      "Experiment: video_2021-02-15T10_18_59_arena5.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 4 \n",
      "Experiment: video_2021-02-15T10_18_59_arena9.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 5 \n",
      "Experiment: video_2021-02-15T11_07_47_arena10.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 6 \n",
      "Experiment: video_2021-02-15T11_07_47_arena15.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 7 \n",
      "Experiment: video_2021-02-15T11_07_47_arena16.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 8 \n",
      "Experiment: video_2021-02-15T11_07_47_arena2.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 9 \n",
      "Experiment: video_2021-02-15T11_07_47_arena9.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 10 \n",
      "Experiment: video_2021-02-16T12_26_11_arena1.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 11 \n",
      "Experiment: video_2021-02-16T12_26_11_arena16.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 12 \n",
      "Experiment: video_2021-02-16T12_26_11_arena2.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 13 \n",
      "Experiment: video_2021-02-16T12_26_11_arena5.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 14 \n",
      "Experiment: video_2021-02-17T10_22_44_arena11.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 15 \n",
      "Experiment: video_2021-02-17T10_22_44_arena2.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 16 \n",
      "Experiment: video_2021-02-17T11_13_09_arena10.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 17 \n",
      "Experiment: video_2021-02-17T11_13_09_arena13.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 18 \n",
      "Experiment: video_2021-02-17T11_13_09_arena15.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 19 \n",
      "Experiment: video_2021-02-17T11_13_09_arena3.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 20 \n",
      "Experiment: video_2021-02-17T11_13_09_arena5.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 21 \n",
      "Experiment: video_2021-02-18T12_15_02_arena10.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 22 \n",
      "Experiment: video_2021-02-19T10_46_46_arena10.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 23 \n",
      "Experiment: video_2021-02-19T10_46_46_arena11.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 24 \n",
      "Experiment: video_2021-02-19T10_46_46_arena13.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 25 \n",
      "Experiment: video_2021-02-19T10_46_46_arena14.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 26 \n",
      "Experiment: video_2021-02-19T10_46_46_arena2.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 27 \n",
      "Experiment: video_2021-02-19T10_46_46_arena3.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 28 \n",
      "Experiment: video_2021-02-19T10_46_46_arena6.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 29 \n",
      "Experiment: video_2021-02-19T10_46_46_arena9.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 30 \n",
      "Experiment: video_2021-02-19T11_33_52_arena5.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 31 \n",
      "Experiment: video_2021-02-19T11_33_52_arena6.csv \n",
      "Condition: test \n",
      "\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>has_aggression</th>\n",
       "      <th>aggression_latency</th>\n",
       "      <th>aggression_latency_mins</th>\n",
       "      <th>nframes</th>\n",
       "      <th>nbouts</th>\n",
       "      <th>ratio_frames</th>\n",
       "      <th>ratio_bouts</th>\n",
       "      <th>condition</th>\n",
       "      <th>experiment</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>True</td>\n",
       "      <td>2601</td>\n",
       "      <td>0.722500</td>\n",
       "      <td>151</td>\n",
       "      <td>6</td>\n",
       "      <td>0.008389</td>\n",
       "      <td>1.2</td>\n",
       "      <td>gal4_control</td>\n",
       "      <td>video_2021-02-15T10_18_59_arena1.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>True</td>\n",
       "      <td>2018</td>\n",
       "      <td>0.560556</td>\n",
       "      <td>101</td>\n",
       "      <td>4</td>\n",
       "      <td>0.005611</td>\n",
       "      <td>0.8</td>\n",
       "      <td>gal4_control</td>\n",
       "      <td>video_2021-02-15T10_18_59_arena10.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>True</td>\n",
       "      <td>527</td>\n",
       "      <td>0.146389</td>\n",
       "      <td>281</td>\n",
       "      <td>12</td>\n",
       "      <td>0.015611</td>\n",
       "      <td>2.4</td>\n",
       "      <td>gal4_control</td>\n",
       "      <td>video_2021-02-15T10_18_59_arena16.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>True</td>\n",
       "      <td>2511</td>\n",
       "      <td>0.697500</td>\n",
       "      <td>278</td>\n",
       "      <td>7</td>\n",
       "      <td>0.015444</td>\n",
       "      <td>1.4</td>\n",
       "      <td>gal4_control</td>\n",
       "      <td>video_2021-02-15T10_18_59_arena6.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>True</td>\n",
       "      <td>3750</td>\n",
       "      <td>1.041667</td>\n",
       "      <td>178</td>\n",
       "      <td>5</td>\n",
       "      <td>0.009889</td>\n",
       "      <td>1.0</td>\n",
       "      <td>gal4_control</td>\n",
       "      <td>video_2021-02-15T10_18_59_arena8.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>88</th>\n",
       "      <td>True</td>\n",
       "      <td>2065</td>\n",
       "      <td>0.573611</td>\n",
       "      <td>146</td>\n",
       "      <td>6</td>\n",
       "      <td>0.008111</td>\n",
       "      <td>1.2</td>\n",
       "      <td>test</td>\n",
       "      <td>video_2021-02-19T10_46_46_arena3.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>89</th>\n",
       "      <td>True</td>\n",
       "      <td>5080</td>\n",
       "      <td>1.411111</td>\n",
       "      <td>559</td>\n",
       "      <td>12</td>\n",
       "      <td>0.031056</td>\n",
       "      <td>2.4</td>\n",
       "      <td>test</td>\n",
       "      <td>video_2021-02-19T10_46_46_arena6.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>90</th>\n",
       "      <td>True</td>\n",
       "      <td>7954</td>\n",
       "      <td>2.209444</td>\n",
       "      <td>40</td>\n",
       "      <td>6</td>\n",
       "      <td>0.002222</td>\n",
       "      <td>1.2</td>\n",
       "      <td>test</td>\n",
       "      <td>video_2021-02-19T10_46_46_arena9.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>91</th>\n",
       "      <td>True</td>\n",
       "      <td>2460</td>\n",
       "      <td>0.683333</td>\n",
       "      <td>197</td>\n",
       "      <td>9</td>\n",
       "      <td>0.010944</td>\n",
       "      <td>1.8</td>\n",
       "      <td>test</td>\n",
       "      <td>video_2021-02-19T11_33_52_arena5.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>92</th>\n",
       "      <td>True</td>\n",
       "      <td>1109</td>\n",
       "      <td>0.308056</td>\n",
       "      <td>251</td>\n",
       "      <td>9</td>\n",
       "      <td>0.013944</td>\n",
       "      <td>1.8</td>\n",
       "      <td>test</td>\n",
       "      <td>video_2021-02-19T11_33_52_arena6.csv</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>93 rows × 9 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    has_aggression  aggression_latency  aggression_latency_mins  nframes  \\\n",
       "0             True                2601                 0.722500      151   \n",
       "1             True                2018                 0.560556      101   \n",
       "2             True                 527                 0.146389      281   \n",
       "3             True                2511                 0.697500      278   \n",
       "4             True                3750                 1.041667      178   \n",
       "..             ...                 ...                      ...      ...   \n",
       "88            True                2065                 0.573611      146   \n",
       "89            True                5080                 1.411111      559   \n",
       "90            True                7954                 2.209444       40   \n",
       "91            True                2460                 0.683333      197   \n",
       "92            True                1109                 0.308056      251   \n",
       "\n",
       "    nbouts  ratio_frames  ratio_bouts     condition  \\\n",
       "0        6      0.008389          1.2  gal4_control   \n",
       "1        4      0.005611          0.8  gal4_control   \n",
       "2       12      0.015611          2.4  gal4_control   \n",
       "3        7      0.015444          1.4  gal4_control   \n",
       "4        5      0.009889          1.0  gal4_control   \n",
       "..     ...           ...          ...           ...   \n",
       "88       6      0.008111          1.2          test   \n",
       "89      12      0.031056          2.4          test   \n",
       "90       6      0.002222          1.2          test   \n",
       "91       9      0.010944          1.8          test   \n",
       "92       9      0.013944          1.8          test   \n",
       "\n",
       "                               experiment  \n",
       "0    video_2021-02-15T10_18_59_arena1.csv  \n",
       "1   video_2021-02-15T10_18_59_arena10.csv  \n",
       "2   video_2021-02-15T10_18_59_arena16.csv  \n",
       "3    video_2021-02-15T10_18_59_arena6.csv  \n",
       "4    video_2021-02-15T10_18_59_arena8.csv  \n",
       "..                                    ...  \n",
       "88   video_2021-02-19T10_46_46_arena3.csv  \n",
       "89   video_2021-02-19T10_46_46_arena6.csv  \n",
       "90   video_2021-02-19T10_46_46_arena9.csv  \n",
       "91   video_2021-02-19T11_33_52_arena5.csv  \n",
       "92   video_2021-02-19T11_33_52_arena6.csv  \n",
       "\n",
       "[93 rows x 9 columns]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "aggression_df = pd.DataFrame()\n",
    "for condition in condition_order:\n",
    "    for h, experiment_path in enumerate(experiments[condition]):\n",
    "\n",
    "        experiment = os.path.basename(experiment_path)\n",
    "        \n",
    "        print('Iteration:', h, '\\nExperiment:', experiment, '\\nCondition:', condition, '\\n')\n",
    "        \n",
    "        # Exclude experiments without copulation (since aggression is only observed during copulation).\n",
    "        annotation_video = annotations.read(experiment_path)\n",
    "        try:\n",
    "            copulation = annotation_video[0].events[0]\n",
    "        except IndexError:\n",
    "            continue\n",
    "        \n",
    "        aggression_events = list(filter(lambda event: event.time < (copulation.time + N_FRAMES), annotation_video[1].events)) # Consider aggression only during the first 5 minutes of copulation.\n",
    "        n_events = len(aggression_events)\n",
    "\n",
    "        # In case there is aggression, do the necessary calculations.\n",
    "        if n_events > 0:\n",
    "            aggression_latency =  aggression_events[0].time - copulation.time\n",
    "            aggression_latency_mins = aggression_latency / (60 * FPS)\n",
    "            ratio_frames = sum([aggression.duration for aggression in aggression_events]) / N_FRAMES\n",
    "            ratio_bouts = n_events / N_MINUTES\n",
    "\n",
    "            aggression_data = pd.DataFrame({'has_aggression': True,\n",
    "                                            'aggression_latency': aggression_latency,\n",
    "                                            'aggression_latency_mins': aggression_latency_mins,\n",
    "                                            'nframes': sum([aggression.duration for aggression in aggression_events]),\n",
    "                                            'nbouts': n_events,\n",
    "                                            'ratio_frames': ratio_frames,\n",
    "                                            'ratio_bouts': ratio_bouts,\n",
    "                                            'condition': condition,\n",
    "                                            'experiment': experiment},\n",
    "                                            index=[h],\n",
    "                                           )\n",
    "\n",
    "        # If not, preset our dictionary with default values.\n",
    "        else:\n",
    "            aggression_data = pd.DataFrame({'has_aggression': False,\n",
    "                                            'aggression_latency': np.nan,\n",
    "                                            'aggression_latency_mins': np.nan,\n",
    "                                            'nframes': 0,\n",
    "                                            'nbouts': 0,\n",
    "                                            'ratio_frames': 0, \n",
    "                                            'ratio_bouts': 0,\n",
    "                                            'condition': condition,\n",
    "                                            'experiment': experiment},\n",
    "                                            index=[h],\n",
    "                                           )\n",
    "        \n",
    "        # Concatenate all data together.\n",
    "        aggression_df = pd.concat([aggression_df, aggression_data], ignore_index=True)\n",
    "\n",
    "aggression_df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Outlier Detection"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\t gal4_control \n",
      "\n",
      "[8, 35]\n",
      "Number data points considered outliers: 2\n",
      "Percent data points considered outliers: 5.0 %\n",
      "\n",
      "\t uas_control \n",
      "\n",
      "[]\n",
      "Number data points considered outliers: 0\n",
      "Percent data points considered outliers: 0.0 %\n",
      "\n",
      "\t test \n",
      "\n",
      "[]\n",
      "Number data points considered outliers: 0\n",
      "Percent data points considered outliers: 0.0 %\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>has_aggression</th>\n",
       "      <th>aggression_latency</th>\n",
       "      <th>aggression_latency_mins</th>\n",
       "      <th>nframes</th>\n",
       "      <th>nbouts</th>\n",
       "      <th>ratio_frames</th>\n",
       "      <th>ratio_bouts</th>\n",
       "      <th>condition</th>\n",
       "      <th>experiment</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>True</td>\n",
       "      <td>2601</td>\n",
       "      <td>0.722500</td>\n",
       "      <td>151</td>\n",
       "      <td>6</td>\n",
       "      <td>0.008389</td>\n",
       "      <td>1.2</td>\n",
       "      <td>gal4_control</td>\n",
       "      <td>video_2021-02-15T10_18_59_arena1.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>True</td>\n",
       "      <td>2018</td>\n",
       "      <td>0.560556</td>\n",
       "      <td>101</td>\n",
       "      <td>4</td>\n",
       "      <td>0.005611</td>\n",
       "      <td>0.8</td>\n",
       "      <td>gal4_control</td>\n",
       "      <td>video_2021-02-15T10_18_59_arena10.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>True</td>\n",
       "      <td>527</td>\n",
       "      <td>0.146389</td>\n",
       "      <td>281</td>\n",
       "      <td>12</td>\n",
       "      <td>0.015611</td>\n",
       "      <td>2.4</td>\n",
       "      <td>gal4_control</td>\n",
       "      <td>video_2021-02-15T10_18_59_arena16.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>True</td>\n",
       "      <td>2511</td>\n",
       "      <td>0.697500</td>\n",
       "      <td>278</td>\n",
       "      <td>7</td>\n",
       "      <td>0.015444</td>\n",
       "      <td>1.4</td>\n",
       "      <td>gal4_control</td>\n",
       "      <td>video_2021-02-15T10_18_59_arena6.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>True</td>\n",
       "      <td>3750</td>\n",
       "      <td>1.041667</td>\n",
       "      <td>178</td>\n",
       "      <td>5</td>\n",
       "      <td>0.009889</td>\n",
       "      <td>1.0</td>\n",
       "      <td>gal4_control</td>\n",
       "      <td>video_2021-02-15T10_18_59_arena8.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>88</th>\n",
       "      <td>True</td>\n",
       "      <td>2065</td>\n",
       "      <td>0.573611</td>\n",
       "      <td>146</td>\n",
       "      <td>6</td>\n",
       "      <td>0.008111</td>\n",
       "      <td>1.2</td>\n",
       "      <td>test</td>\n",
       "      <td>video_2021-02-19T10_46_46_arena3.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>89</th>\n",
       "      <td>True</td>\n",
       "      <td>5080</td>\n",
       "      <td>1.411111</td>\n",
       "      <td>559</td>\n",
       "      <td>12</td>\n",
       "      <td>0.031056</td>\n",
       "      <td>2.4</td>\n",
       "      <td>test</td>\n",
       "      <td>video_2021-02-19T10_46_46_arena6.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>90</th>\n",
       "      <td>True</td>\n",
       "      <td>7954</td>\n",
       "      <td>2.209444</td>\n",
       "      <td>40</td>\n",
       "      <td>6</td>\n",
       "      <td>0.002222</td>\n",
       "      <td>1.2</td>\n",
       "      <td>test</td>\n",
       "      <td>video_2021-02-19T10_46_46_arena9.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>91</th>\n",
       "      <td>True</td>\n",
       "      <td>2460</td>\n",
       "      <td>0.683333</td>\n",
       "      <td>197</td>\n",
       "      <td>9</td>\n",
       "      <td>0.010944</td>\n",
       "      <td>1.8</td>\n",
       "      <td>test</td>\n",
       "      <td>video_2021-02-19T11_33_52_arena5.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>92</th>\n",
       "      <td>True</td>\n",
       "      <td>1109</td>\n",
       "      <td>0.308056</td>\n",
       "      <td>251</td>\n",
       "      <td>9</td>\n",
       "      <td>0.013944</td>\n",
       "      <td>1.8</td>\n",
       "      <td>test</td>\n",
       "      <td>video_2021-02-19T11_33_52_arena6.csv</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>91 rows × 9 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    has_aggression  aggression_latency  aggression_latency_mins  nframes  \\\n",
       "0             True                2601                 0.722500      151   \n",
       "1             True                2018                 0.560556      101   \n",
       "2             True                 527                 0.146389      281   \n",
       "3             True                2511                 0.697500      278   \n",
       "4             True                3750                 1.041667      178   \n",
       "..             ...                 ...                      ...      ...   \n",
       "88            True                2065                 0.573611      146   \n",
       "89            True                5080                 1.411111      559   \n",
       "90            True                7954                 2.209444       40   \n",
       "91            True                2460                 0.683333      197   \n",
       "92            True                1109                 0.308056      251   \n",
       "\n",
       "    nbouts  ratio_frames  ratio_bouts     condition  \\\n",
       "0        6      0.008389          1.2  gal4_control   \n",
       "1        4      0.005611          0.8  gal4_control   \n",
       "2       12      0.015611          2.4  gal4_control   \n",
       "3        7      0.015444          1.4  gal4_control   \n",
       "4        5      0.009889          1.0  gal4_control   \n",
       "..     ...           ...          ...           ...   \n",
       "88       6      0.008111          1.2          test   \n",
       "89      12      0.031056          2.4          test   \n",
       "90       6      0.002222          1.2          test   \n",
       "91       9      0.010944          1.8          test   \n",
       "92       9      0.013944          1.8          test   \n",
       "\n",
       "                               experiment  \n",
       "0    video_2021-02-15T10_18_59_arena1.csv  \n",
       "1   video_2021-02-15T10_18_59_arena10.csv  \n",
       "2   video_2021-02-15T10_18_59_arena16.csv  \n",
       "3    video_2021-02-15T10_18_59_arena6.csv  \n",
       "4    video_2021-02-15T10_18_59_arena8.csv  \n",
       "..                                    ...  \n",
       "88   video_2021-02-19T10_46_46_arena3.csv  \n",
       "89   video_2021-02-19T10_46_46_arena6.csv  \n",
       "90   video_2021-02-19T10_46_46_arena9.csv  \n",
       "91   video_2021-02-19T11_33_52_arena5.csv  \n",
       "92   video_2021-02-19T11_33_52_arena6.csv  \n",
       "\n",
       "[91 rows x 9 columns]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "corrected_ratio_frames = pd.DataFrame()\n",
    "\n",
    "for condition in condition_order:\n",
    "\n",
    "    print('\\n\\t', condition, '\\n')\n",
    "\n",
    "    try:\n",
    "        dataset = aggression_df.query('condition==\"' + condition + '\"')['ratio_frames']\n",
    "\n",
    "        outlier_positions = helpers.check_outliers(dataset)\n",
    "        print(outlier_positions)\n",
    "\n",
    "        fresh_dataset = pd.DataFrame(helpers.remove_outliers(dataset, indices=outlier_positions))\n",
    "        fresh_dataset['condition'] = condition\n",
    "\n",
    "        corrected_ratio_frames = pd.concat([corrected_ratio_frames, fresh_dataset], axis=0)\n",
    "        \n",
    "    except ValueError as error:\n",
    "        print(error)\n",
    "\n",
    "aggression_df = aggression_df.loc[corrected_ratio_frames.index]\n",
    "aggression_df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Aggression Rate"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>condition</th>\n",
       "      <th>ratio_frames</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>gal4_control</td>\n",
       "      <td>0.008389</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>gal4_control</td>\n",
       "      <td>0.005611</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>gal4_control</td>\n",
       "      <td>0.015611</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>gal4_control</td>\n",
       "      <td>0.015444</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>gal4_control</td>\n",
       "      <td>0.009889</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>88</th>\n",
       "      <td>test</td>\n",
       "      <td>0.008111</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>89</th>\n",
       "      <td>test</td>\n",
       "      <td>0.031056</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>90</th>\n",
       "      <td>test</td>\n",
       "      <td>0.002222</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>91</th>\n",
       "      <td>test</td>\n",
       "      <td>0.010944</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>92</th>\n",
       "      <td>test</td>\n",
       "      <td>0.013944</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>91 rows × 2 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       condition  ratio_frames\n",
       "0   gal4_control      0.008389\n",
       "1   gal4_control      0.005611\n",
       "2   gal4_control      0.015611\n",
       "3   gal4_control      0.015444\n",
       "4   gal4_control      0.009889\n",
       "..           ...           ...\n",
       "88          test      0.008111\n",
       "89          test      0.031056\n",
       "90          test      0.002222\n",
       "91          test      0.010944\n",
       "92          test      0.013944\n",
       "\n",
       "[91 rows x 2 columns]"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ratio_frames_df = aggression_df.copy()[['condition', 'ratio_frames']]\n",
    "ratio_frames_df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Statistics"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\t gal4_control \n",
      "\n",
      "Shapiro's Test: group 1 IS normally distributed.\n",
      "D'Agostino's Test: group 1 IS normally distributed.\n",
      "Shapiro's Test: group 2 IS NOT normally distributed.\n",
      "D'Agostino's Test: group 2 IS NOT normally distributed.\n",
      "Levene's Test for non-normally distributed samples:\n",
      "  p-value = 0.065614\n",
      "  All groups were sampled from populations with IDENTICAL variances.\n",
      "\n",
      "Mann-Whitney p-value: 0.03703596803831396 \n",
      "\n",
      "\n",
      "\t uas_control \n",
      "\n",
      "Shapiro's Test: group 1 IS NOT normally distributed.\n",
      "D'Agostino's Test: group 1 IS normally distributed.\n",
      "Shapiro's Test: group 2 IS NOT normally distributed.\n",
      "D'Agostino's Test: group 2 IS NOT normally distributed.\n",
      "Levene's Test for non-normally distributed samples:\n",
      "  p-value = 0.193649\n",
      "  All groups were sampled from populations with IDENTICAL variances.\n",
      "\n",
      "Mann-Whitney p-value: 0.2958005730885349 \n",
      "\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'gal4_control': 0.03703596803831396, 'uas_control': 0.2958005730885349}"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ratio_frames_pvalues = {}\n",
    "\n",
    "test = ratio_frames_df.query('condition==\"test\"')['ratio_frames']\n",
    "\n",
    "for condition in condition_order[:-1]:\n",
    "        \n",
    "    print('\\n\\t', condition, '\\n')\n",
    "\n",
    "    try:\n",
    "        control = ratio_frames_df.query('condition==\"' + condition + '\"')['ratio_frames']\n",
    "\n",
    "        temp_values = {'control': control, 'test': test}\n",
    "\n",
    "        pvalue_condition = helpers.run_statistics(temp_values)\n",
    "\n",
    "        ratio_frames_pvalues[condition] = pvalue_condition\n",
    "    \n",
    "    except ValueError as error:\n",
    "        print(error)\n",
    "    \n",
    "ratio_frames_pvalues"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Bonferroni Correction\n",
      "---------------------\n",
      "\n",
      "\tOriginal Values:\n",
      " {'gal4_control': 0.03703596803831396, 'uas_control': 0.2958005730885349}\n",
      "\n",
      "\tCorrected Values:\n",
      " {'gal4_control': 0.07407193607662792, 'uas_control': 0.5916011461770698} \n",
      "\n"
     ]
    }
   ],
   "source": [
    "# Bonferroni corretction for multiple comparisons.\n",
    "title = 'Bonferroni Correction'\n",
    "print(title)\n",
    "print('-'*len(title))\n",
    "\n",
    "# Show uncorrected values.\n",
    "print('\\n\\tOriginal Values:\\n', ratio_frames_pvalues)\n",
    "\n",
    "# Apply the bonferroni correction for multiple comparisons.\n",
    "ratio_frames_multi_comp_correction = multipletests(pvals=list(ratio_frames_pvalues.values()), alpha=0.05, method='bonferroni')[1]\n",
    "\n",
    "# Transform the correction results into a dictionary.\n",
    "corrected_ratio_frames_pvalues = dict(zip(list(ratio_frames_pvalues.keys()), ratio_frames_multi_comp_correction))\n",
    "\n",
    "# Show corrected values.\n",
    "print('\\n\\tCorrected Values:\\n', corrected_ratio_frames_pvalues, '\\n')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Effect Size"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "gal4_control\n",
      "Small Effect: -0.3952380952380953 \n",
      "\n",
      "uas_control\n",
      "Small Effect: -0.24103585657370522 \n",
      "\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'gal4_control': -0.3952380952380953, 'uas_control': -0.24103585657370522}"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ratio_frames_sizes = {}\n",
    "\n",
    "test = ratio_frames_df.query('condition==\"test\"')['ratio_frames']\n",
    "\n",
    "for condition in condition_order[:-1]:\n",
    "\n",
    "    print(condition)\n",
    "    \n",
    "    control = ratio_frames_df.query('condition==\"' + condition + '\"')['ratio_frames']\n",
    "\n",
    "    median_diff = helpers.get_effect_size(control, test, method='median_diff')\n",
    "    \n",
    "    ratio_frames_sizes[condition] = median_diff\n",
    "    \n",
    "ratio_frames_sizes"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Plot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAP4AAAEgCAYAAACU1c66AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+j8jraAAAgAElEQVR4nOzddXQUVxvA4d9KsvGEOJYQQtDgFtzdIQ0p7lbcKRYohaItEOBDSnG34FKKFXcvThIs7rY23x+hoSkQFppks2Sec/YcMju7884w786dO1ckgiAIiESiXEWq7wBEIlH2ExNfJMqFxMQXiXIhMfFFolxITHyRKBcSE18kyoWyPPHXrVtHuXLl0l5ubm4YGRkREhKS1ZsWiUQfIcnO5/gqlYratWvTo0cP+vfvn12bFYlE/5KtRf3Zs2fj6OgoJr1IpGfZdsUPDw/Hw8ODq1evUrhw4ezYpEgk+ohsu+KvWLGCNm3aZJj0fn5+SCSStJdIJMoa2XbFL1u2LIsWLaJOnTo6rS+RSBC7EYhEWSNbEj8qKooCBQoQHR2NkZGRTp8RE18kyjrZUtR//PgxefPm1TnpRSJR1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OGzp8/T0RE7e3tFBYWRqtXr1a7nM5dWGNjY0kikVBNTc2zWQkN0LXtwhK/F7T19tXTeFwDl8lkZGxsTCUlJWRsbExyuZyrM3ToUO4qORFRVVUVZWVlqV3Ogwa+Z88ecnFxIZlMxv3twRX2kpIScnBwIE9PT5oxY8YzWsOno2vbhR3qMyqSk5Ph5eUFGxsbjBs3DocPH+b+9sUXX8DHxwf29vZYsWIFLl26BA8Pj24/Ky4uDhEREVi5ciVMTU3V1ikqKkJycjJOnTr1zNflWXretgtL/B5ocxfVpyUUdv3KiYg7l01KSsJbb70FAFi8eDHi4+O5ekFBQaiursaOHTvQv39/BAUFISIiottlSaVSHDt2DOvWrUN5ebnaOmZmZmrPrfuazm0XjRxHPGeep0P9hoYGGjp0qEpZdXU1DRs2jC5dukRCoZCsrKzI2tqaLC0tSSgUUlZWFhUXF1N0dLTKfEVFRWRgYEBERM7OztxE1HFIW1RUREREH330EXl6elJbWxsRqR7Sqju85oOubRe2x9cxRkZGsLe3R0pKCleWkJCAGTNmIDExEStWrEB5eTlKS0tRUVGBpUuXIj4+HsOHD8eePXtw9uxZbr7c3Fy4uroCAPLy8rjpgQEDBgAANm/ejPv372vdq6I707ntotGfFUYrFRUV0bRp08jJyYnGjBlDfn5+VFNTQy+88ALl5+er1L1y5QoNGjSI6uvrKTs7myZNmkQvv/wyOTg4kI+PD5WXl6tdxqMDU1y/fp0MDQ0pIyNDK/f4RLq1XVgHHobRQexQn2F0EEt8htFBLPEZRgexxGcYHcQSn2F0EEt8htFBLPEZRgexxGcYHcQSn2F0EEt8htFB/w9KpfQRC/X06AAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 270x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Initialize figure.\n",
    "n_conditions = ratio_frames_df['condition'].nunique()\n",
    "figure, axis = plt.subplots(figsize=(1.25*n_conditions, 4))\n",
    "\n",
    "# Draw the boxplot.\n",
    "sns.boxplot(x='condition',\n",
    "            y='ratio_frames',\n",
    "            data=ratio_frames_df,\n",
    "            order=condition_order,\n",
    "            width=0.6,\n",
    "            showfliers=False,\n",
    "            palette=['#b8f2e6', '#b8f2e6', '#0081a7'],\n",
    "            boxprops={'edgecolor': INK},\n",
    "            medianprops={'color': INK},\n",
    "            whiskerprops={'color': INK},\n",
    "            capprops={'color': INK},\n",
    "           )\n",
    "\n",
    "# Draw the swarmplot.\n",
    "sns.swarmplot(x='condition',\n",
    "              y='ratio_frames',\n",
    "              data=ratio_frames_df,\n",
    "              order=condition_order,\n",
    "              palette=['#b8f2e6', '#b8f2e6', '#0081a7'],\n",
    "              linewidth=0.75,\n",
    "              edgecolor=INK\n",
    "             )\n",
    "\n",
    "# Figure and axes formatting.\n",
    "axis.set_xlabel('')\n",
    "axis.set_xticklabels([''])\n",
    "axis.set_ylabel('Aggression Rate (%)')\n",
    "axis.set_ylim(0, 0.07)\n",
    "axis.set_yticks(np.arange(0, 0.07+0.001, 0.01))\n",
    "axis.set_yticklabels([int(y*100) for y in axis.get_yticks()])\n",
    "\n",
    "# Table definition.\n",
    "row1 = [str(ratio_frames_df.query('condition==\"'+condition+'\"').shape[0]) for condition in condition_order]\n",
    "row2 = ['OR67d-GAL4;\\n+', '+;\\nUAS-Kir', 'OR67d-GAL4;\\nUAS-Kir']\n",
    "cell_text = np.array([row1, row2])\n",
    "\n",
    "row_labels = ['n =', '']\n",
    "summary_table = axis.table(cellText= cell_text,\n",
    "                           cellLoc='center',\n",
    "                           rowLabels=row_labels,\n",
    "                           rowLoc='center',\n",
    "                           colLoc='center',\n",
    "                          )\n",
    "\n",
    "summary_table.auto_set_font_size(False)\n",
    "summary_table.set_fontsize(11)\n",
    "\n",
    "properties = summary_table.properties()\n",
    "table_cells = properties['children']\n",
    "for cell in table_cells:\n",
    "    cell.set_height(0.12)\n",
    "    cell.set_alpha(0)\n",
    "\n",
    "# Draw statistical results.\n",
    "for p, condition in enumerate(condition_order[:-1]):\n",
    "    sig_height = 6 if (corrected_ratio_frames_pvalues.get(condition, 'NaN') == 'NaN') or (corrected_ratio_frames_pvalues.get(condition, 'NaN') >= 0.05) else 2\n",
    "    helpers.plot_stattest_result(ax=axis,\n",
    "                                 x1=1-p,\n",
    "                                 x2=1-p,\n",
    "                                 p_value=corrected_ratio_frames_pvalues.get(condition, 'NaN'),\n",
    "                                 y=0.065,\n",
    "                                 ticksize=0,\n",
    "                                 xytext=(0,sig_height),\n",
    "                                 fontsize=13,\n",
    "                                 color=INK,\n",
    "                                 connector_color=INK\n",
    "                                )\n",
    "\n",
    "# Saving parameters.\n",
    "filename = 'aggression_rate_5mins_Or67d'\n",
    "plt.savefig(os.path.join(savepath, filename))\n",
    "\n",
    "plt.show()\n",
    "plt.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
